package com.tanhua.dubbo.server.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.common.mapper.SoulOptionMapper;
import com.tanhua.common.pojo.SoulOption;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @ClassName: SoulOptionService
 * @Author:王晨晗
 * @Description: 题目选项业务层
 * @Date: 2022/01/10/17:15
 */
@Service
public class SoulOptionService {
    @Autowired
    private SoulOptionMapper soulOptionMapper;

    /**
     * @description 根据题目id获取选项
     * @param id
     * @return
     */
    public List<SoulOption> findById(Long id){
        //创建查询对象
        QueryWrapper<SoulOption> wrapper = new QueryWrapper<>();
        //构建查询条件
        wrapper.eq("question_id",id);
        //执行查询,得到选项集合
        return soulOptionMapper.selectList(wrapper);
    }

    /**
     * @description 根据选项id 获取得分
     * @param optionId
     * @return
     */
    public SoulOption getOption(Long optionId) {
        //创建查询对象
        QueryWrapper queryWrapper = new QueryWrapper();
        //构建查询条件
        queryWrapper.eq("id", optionId);
        //执行查询,获取到选项
        SoulOption soulOption = soulOptionMapper.selectOne(queryWrapper);
        //返回该选项的得分;
        return soulOption;
    }
}
